(defparameter *account-number* 0)

;;cry

(defparameter *super-user* 
  (let ((code 2))
	#'(lambda () (setf code (find-next-prime code)))))
 
(defun prime-p (number )
  (loop for num from 2 to (isqrt number) never (zerop (mod number num)))) 
(defun find-next-prime (number)	     
  (loop for num from (+ 1 number) when (prime-p num) return num))



(defclass bank-account ()
  ((customer-name 
    :initarg :customer-name
    :initform (error "no name pride")
    :accessor customer-name)
   (balance 
    :initarg :balance
    :initform 10
    :reader balance )
   (account-number
    :initform (incf *account-number*)
    :reader account-number)
   (account-type
    :reader account-type))))

(defmethod initialize-instance :after  ((account bank-account) &key)
  (let ((balance (slot-value account 'balance)))
    (setf (slot-value account 'account-type)
	  (cond
	    ((>= balance 100000) :gold-account)
	    ((>= balance 50000) :sliver-account)
	    (t :bronze-account)))))

(defmethod initialize-instance :after ((account bank-account) &key opening-bonus-percentage)
  (when opening-bonus-percentage
    (incf (slot-value account 'balance) 
	  (* (slot-value account 'balance) (/ opening-bonus-percentage 100)))))
c
;; structure

(defun balance-search (account &key (password 0))
  (if 
   (= password (funcall *super-user*))
   (balance-search-assistant account customer-name balance account-type)
   (slot-value account 'balance)))

(defmacro balance-search-assistant (account &rest sequce)
  `(list ,@(loop for i in sequce collect `(slot-value ,account  ',i))))

(defun search-cry ()
  (let ((now (funcall *super-user*)))
    (find-next-prime now)))

(defmethod search_all ((account bank-account ) &key )
  `(balance-search ,account :password ,(search-cry)))


